const HtmlWebpackPlugin = require("html-webpack-plugin");

module.exports = {
    // 主入口文件
    entry: __dirname + '/index.js',
    // 输出文件
    output: {
        filename: 'bundle.js',
        path: __dirname + "/dist"
    },
    // 开发模式
    mode: "development",
    // mode: "production",
    // 插件
    plugins: [
        new HtmlWebpackPlugin({
            template: 'index.html',  // Path to your HTML file
            filename: 'index.html',  // Output HTML filename
        })
    ],
    // 添加loader
    module: {
        rules: [
          {
            test: /\.js$/,
            use: {
              loader: "babel-loader"
            },
            exclude: /node_modules/
          },
          // 添加css-loader, style-loader
          {
            test: /\.css$/,
            use: ["style-loader", "css-loader"]
          } ,
        ]
    }
}